Skip to content

feat(rw-backend): materialize effective section ownership in siteIndex#74

Merged
yumike merged 1 commit into
mainfrom
feat/section-ownership-rollup
Jun 25, 2026
Merged

feat(rw-backend): materialize effective section ownership in siteIndex#74
yumike merged 1 commit into
mainfrom
feat/section-ownership-rollup

Conversation

@yumike

@yumike yumike commented Jun 25, 2026

Copy link
Copy Markdown
Contributor

Summary

Extracts the effective section-ownership rollup out of the larger feat/doc-comment-inbox branch into a standalone change off main, to shrink the inbox PR. Infra-only.

The siteIndex worker already materializes the dense sections registry from RwSite.listSections(). This adds a rollup layer: the worker loads per-site ownership claims (written to section_ownership by the scan) and folds an effective owner into every section row.

  • migration: add entity_ref / entity_owner_ref + sections_owner_idx to sections (edited in place — siteIndex is unreleased)
  • effectiveOwnership.ts: pure computeSectionRows — attributes each section to its nearest claiming ancestor, falls back to the site-root sentinel then a null owner, and strips the claimer's path prefix so section_path is owner-relative
  • SectionOwnershipStore.listForSite: read side for the worker
  • runWorker: fetch claims alongside listSections/listPages and roll them up
  • plugin.ts: pass the existing sectionOwnershipStore into the worker

Scope

No consumer reads the new columns yet — the comment inbox (a separate change) is the first reader. This is deliberate pre-positioning.

Known deferred debt

The scan (writes claims) and worker (reads claims) couple through section_ownership with no read-time consistency guard. Bounded and self-healing within ~one scan cycle, since ownership is part of the hashed SectionRow. The inbox PR (first reader) should revisit before adding generation plumbing.

Testing

  • effectiveOwnership unit tests (nearest-ancestor, sentinel fallback, null-owner, path-boundary stripping)
  • SectionOwnershipStore.listForSite, runWorker rollup + hash-stability, migration schema test
  • Full rw-backend suite: 138/138 passing; typecheck + lint clean
  • Verified live via yarn dev: 3 claims rolled up into 1368 attributed sections, owner-relative paths, no errors

🤖 Generated with Claude Code

The siteIndex worker already materializes the dense `sections` registry from
RwSite.listSections(). This adds an effective-ownership rollup: the worker now
loads per-site ownership claims (written to section_ownership by the scan) and
folds an effective owner into every section row.

- migration: add entity_ref / entity_owner_ref + sections_owner_idx to `sections`
  (edited in place — siteIndex is unreleased)
- effectiveOwnership.ts: pure computeSectionRows — attributes each section to its
  nearest claiming ancestor, falls back to the site-root sentinel then a null
  owner, and strips the claimer's path prefix so section_path is owner-relative
- SectionOwnershipStore.listForSite: read side for the worker
- runWorker: fetch claims alongside listSections/listPages and roll them up
- plugin.ts: pass the existing sectionOwnershipStore into the worker

Infra-only: no consumer reads the new columns yet (the comment inbox, a separate
change, is the first reader). Known deferred debt: the scan (writes claims) and
worker (reads claims) couple through section_ownership with no read-time
consistency guard; bounded and self-healing within ~one scan cycle since
ownership is part of the hashed SectionRow.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@yumike yumike merged commit 21f7f14 into main Jun 25, 2026
1 check passed
@yumike yumike deleted the feat/section-ownership-rollup branch June 25, 2026 03:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant